//
//  StatusIndicatorView.m
//  Meal4iOS
//
//  Created by XiguaZerg on 12-8-20.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "StatusIndicatorView.h"

#import "Contants.h"

@implementation StatusIndicatorView

@synthesize statusText = _statusText;
@synthesize processBar = _processBar;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        _backgroundView = [[UIView alloc] initWithFrame:self.bounds];
        _backgroundView.backgroundColor = [UIColor blackColor];
        _backgroundView.alpha = 0.7f;
        _backgroundView.layer.cornerRadius = 15.0f;
        _backgroundView.layer.masksToBounds = YES;
        _backgroundView.layer.borderColor = kCommonGreenStartColor.CGColor;
        _backgroundView.layer.borderWidth = 4.0f;
        [self addSubview:_backgroundView];
        [_backgroundView release];
        
        _processBar = [[EProcessBar alloc] initWithColors:[NSArray arrayWithObjects:kEProcessBarFirstColor, kEProcessBarSecondColor, nil]];
        _processBar.frame = CGRectMake(10.0f, 15.0f, self.frame.size.width - 20.0f, 20.0f);
        _processBar.contentMode = UIViewContentModeCenter;
        [self addSubview:_processBar];
        
        _statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 45.0f, self.frame.size.width - 20.0f, 20.0f)];
        _statusLabel.backgroundColor = [UIColor clearColor];
        _statusLabel.textColor = [UIColor whiteColor];
        _statusLabel.font = [UIFont boldSystemFontOfSize:20.0f];
        _statusLabel.textAlignment = UITextAlignmentCenter;
        [self addSubview:_statusLabel];
        [_statusLabel release];
    }
    return self;
}

- (void)setStatusText:(NSString *)statusText {

    [_statusText release];
    
    _statusText = [statusText retain];
    _statusLabel.text = _statusText;
}

- (void)dealloc {

    [_processBar release];
    [_statusText release];
    
    _processBar = nil;
    _statusText = nil;
    
    [super dealloc];
}

@end
